<%@ page import="com.system.dao.DoctorDao"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="ui" uri="http://com.am.tag"%>
<%@ include file="../common.jsp" %>
<%
	DoctorDao dao = new DoctorDao();
	String record_id = request.getParameter("record_id");
	String person_id = request.getParameter("person_id");
	Map<String,Object> map = dao.getDiagnoseInfo(record_id,person_id);
	
	pageContext.setAttribute("list", map.get("list"));
	pageContext.setAttribute("personMap", map.get("personMap"));
	pageContext.setAttribute("diagnoseMap", map.get("diagnoseMap"));
	
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  
    <title>My JSP 'doctor.jsp' starting page</title>
    <link rel="stylesheet" href="${path }/css/easyui.css" type="text/css"></link>
	<script type="text/javascript" src="${path }/js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${path }/js/public/autocomplete.js"></script>
	<link type="text/css" rel="stylesheet" href="${path }/css/showtable.css"/>
     
     <style type="text/css">
		body{
			overflow-x: hidden;
			overflow-y: auto;
		}
		.top{
			width:99%;
			float:left;
			margin-top:10px;
			margin-left:5px;
			margin-right:10px;
		}
		.sub_top{
			padding-right:30px;
			float:left;
			font-size:14px;
		}
		.left_main{
			width: 75%;
			float:left;
		}
		.right_main{
			float: right;
		}
		.main_div{
			width: 100%;
			margin-left:10px;
			margin-top:5px;
		}
		.remind_main{
			background-color:#CAEDEB;
		}

		.item {
			text-align:left;
		}
		.study_table{
			width:100%;
			height:150px;
			border-left: 1px solid #DEDEDE;
			border-bottom: 1px solid #DEDEDE;
			border-right: 1px solid #DEDEDE;
		}
		.title_bg{
			background-color: #CAEDEB;
		}
		.study_table th, .study_table td{
			border-left: 1px solid #DEDEDE;
			border-bottom: 1px solid #DEDEDE;
			border-right: 1px solid #DEDEDE;
		}
		.oper{
			text-decoration:none;
			color:#3399CC;
		}
		.oper:hover{
			text-decoration:underline;
		}
		.moreCls{
			text-decoration:none;
			color:#F0B05B;
			font-size: 11;
		}
		.tip_div{
			
			color: white; 
			font-weight: bold;
			background-color: #60CCB1;
			border: 1px solid #B6CBDD;
		}
		.tip_item{
			width: 28px;
			height: 25px;
			display:inline;
		}
		.tip1{
			background: url(${path }/images/tip_bg.png) -28 0;
		}
		.tip2{
			background: url(${path }/images/tip_bg.png) -57 0;
		}
		.tip3{
			background: url(${path }/images/tip_bg.png) -57 0;
		}
		.tip4{
			background: url(${path }/images/tip_bg.png) -87 0;
		}
		.tip5{
			background: url(${path }/images/tip_bg.png) -2 0;
		}

		#remindDiv {
			height:291px;
	    	overflow: auto;
		}
		#remindDiv2 {
	    	height: 300px;
	  	  overflow: auto;
		}
		#remindDiv ul{
			margin-top:10px;
			margin-bottom:30px;
		}
		#remindDiv ul li {
	   	 border-bottom: 1px dotted #BBBBBB;
	   	 margin-left:-10px;
	   	 margin-top:5px;
		}
		font{
			font-weight:bold;
			font-size:13px;
		}
	
		.count_table{
			width: 100%;
		}
		.count_td{
			background-color: #CAEDEB;
			border-top: 2px solid white;
			font-size: 12px;
			color: #666666;
		}
		.border_right{
			border-right: 2px solid white;
		}
		.tipCls{
			font-family: "微软雅黑", Verdana, Arial, Helvetica, sans-serif;
			font-size: 15px;
			color: #ff0033;
		}
		
		.normalKw {
			color:gray;
			border:0;
			width: 210px;
			height:15px;
			margin-left:-5px;
		}
		
		.normalKw2{
			border:0;
			width: 200px;
			height:15px;
			margin-left:-5px;
		}
		
		.foucsKw {
			border:0;
			width: 210px;
			margin-left:-5px;
		}
		
		.kucun{
			color:green;
		}
		#general{
			width:15px;
			BORDER-RIGHT: medium none;
			BORDER-TOP: medium none;
			BORDER-LEFT: medium none;
			BORDER-BOTTOM: rgb(192,192,192) 1px solid;
			text-align:center;
		}
	</style>
     <script type="text/javascript">
    	var record_id = "${param.record_id}";
     
     	/*添加水印效果*/
		function addWaterMark(obj) {
			obj.className = 'normalKw';
			
			if(!obj.value) {
				obj.value = "输入药品名/药品拼音";
				obj.style.color = 'gray';
			}
		}

		/*去除水印效果*/
		function removeWaterMark(obj) {
			obj.className = 'foucsKw';
			
			if(obj.value == "输入药品名/药品拼音") {
				obj.value = "";
				obj.style.color = '#000000';
			}
		}
     
 		var count = 1;
 		
 		function deleteRow(obj)
 		{
 			$obj = $(obj);
 			$obj.parent().parent().remove();
 			resetNum();
 		}
 		
 		function resetNum(flag)
		{
 			//flag 0——西药  1——中药
 			if(flag == 0){
 				$("#tableid td[name='td_num']").each(function(i){
 					$(this).html(i+1);	
 				});
 			}else{
 				$("#chineseTable td[name='td_num']").each(function(i){
 					$(this).html(i+1);	
 				});
 			}
			
		}
 		
 		//默认当前的tab是公费
    	var currentTab = "western";
    	
		$().ready(function() {
			//判断是否有帖数
			var post_number = "${diagnoseMap['post_number']}";
			if($.trim(post_number) != "")
			{
				currentTab = "chinese";
			}
			
			if(currentTab == "western"){
				$('#div_tabs').tabs( "select" ,0);
			}else{
				$('#div_tabs').tabs( "select" ,1);
				$("#span_description").html("中医诊断");
			}
			
			
			$('#div_tabs').tabs({
	   			 onSelect: function (title) {
	   				 if(title == "中药处方"){
	   					$("#span_description").html("中医诊断");
	   					currentTab = "chinese";
	   				 }else{
	   					$("#span_description").html("诊断描述");
	   					currentTab = "western";
	   				 }
	   				 $("#westernDiv").css("display","");
	   				 $("#chineseDiv").css("display","");
	   			 }
   			});
			
			countAmount();
			
			//西药的自动完成加载
			$("input[name='western_drug_name']").each(function(){
				$(this).autocomplete(
						"${path}/auto?method=getDrugList&campus=${currentUserCampus}",
						{
							max : 12, //列表里的条目数 
							minChars : 1, //自动完成激活之前填入的最小字符 
							width : 215, //提示的宽度，溢出隐藏 
							scrollHeight : 300, //提示的高度，溢出显示滚动条 
							matchContains : false, //包含匹配，就是data参数里的数据，是否只要包含文本框里的数据就显示 
							autoFill : false, //自动填充 
							parse: function(data){    
	                             var rows = [];    
	                             var d = data;    
	                             for(var i=0; i<d.length; i++){    
	                              rows[rows.length] = {    
	                                data:d[i], //每条数据对象   
	                                value:d[i].name+d[i].pin_yin, //与输入的值比较的数据  
	                                result:d[i].name  //选中的实际数据  
	                              };    
	                             } 
	                             return rows;    
	                         },
							formatItem : function(row, i, max) {
								return "<div style='float:left'>" + row.name + "</div>"
										+"<div style='float:right' class='kucun';>库存："+ row.drugstore_num +"</div>";
							},
							formatMatch : function(row, i, max) {
								return row.name;
							},
							formatResult : function(row) {
								return row.name;
							}
						}).result(function(event, row, formatted) {
						
							$(this).parent().parent().find("input[name='spec']").val(row.spec);
							$(this).parent().parent().find("input[name='drugId']").val(row.id);
							$(this).parent().parent().find("input[name='supply_price']").val(row.supply_price);
					});
			});
			
			//中药的自动完成加载
			$("input[name='chinese_drug_name']").each(function(){
				$(this).autocomplete(
						"${path}/auto?method=getDrugList&campus=${currentUserCampus}",
						{
							max : 12, //列表里的条目数 
							minChars : 1, //自动完成激活之前填入的最小字符 
							width : 215, //提示的宽度，溢出隐藏 
							scrollHeight : 300, //提示的高度，溢出显示滚动条 
							matchContains : false, //包含匹配，就是data参数里的数据，是否只要包含文本框里的数据就显示 
							autoFill : false, //自动填充 
							parse: function(data){    
	                             var rows = [];    
	                             var d = data;    
	                             for(var i=0; i<d.length; i++){    
	                              rows[rows.length] = {    
	                                data:d[i], //每条数据对象   
	                                value:d[i].name+d[i].pin_yin, //与输入的值比较的数据  
	                                result:d[i].name  //选中的实际数据  
	                              };    
	                             } 
	                             return rows;    
	                         },
							formatItem : function(row, i, max) {
								return "<div style='float:left'>" + row.name + "</div>"
										+"<div style='float:right' class='kucun';>库存："+ row.drugstore_num +"</div>";
							},
							formatMatch : function(row, i, max) {
								return row.name;
							},
							formatResult : function(row) {
								return row.name;
							}
						}).result(function(event, row, formatted) {
						
							$(this).parent().parent().find("input[name='spec']").val(row.spec);
							$(this).parent().parent().find("input[name='drugId']").val(row.id);
							$(this).parent().parent().find("input[name='supply_price']").val(row.supply_price);
					});
			});
			
			document.onkeydown = function(){
				if(event.keyCode == 32)
				{
					if(currentTab == "western"){
						doWesternClick();
					}else{
						doChineseClick();
					}
				}
			};
		});
			
			
			
			
			

		//西药的处理方式
		
		function doWesternClick()
		{
			var html = "<tr height='25px'><td width='30px' align='center' name='td_num'></td><td width='170px' align='center'><input type='hidden' name='drugId'/><input type='text'  name='drugName' value='输入药品名/药品拼音' class='normalKw'  onfocus='removeWaterMark(this);' onblur='addWaterMark(this);' id='western_drug_name_"+count+"'></td>"
	         + "<td align='center'><input type='text' name='spec' readonly style='border:0;width:80px; text-align:center'></td>"
	         + "<td align='center'><input type='text' name='drugstore_num' readonly style='border:0;width:50px;text-align:center' text-align:center'></td>"
	         + "<td align='center'><input type='text' name='quantity' style='border:0;width:50px;text-align:center;' onkeyup='countAmount()'></td>"
	         +"<td style='display:none'><input type='text' name='supply_price' style='border:0;width:50px' text-align:center'></td>"
	         + "<td align='center' name='td_method'><ui:select pvalue='method' name=''/></td>"
	         + "<td align='center' name='consumption'><input id='general'/><select style='width:40px'><option>粒</option><option>片</option><option>瓶</option><option>ml</option><option>mg</option><option>g</option><option>枚</option><option>丸</option><option>#</option></select></td>"
	         + "<td align='center' name='td_times'><ui:select pvalue='times' name=''/></td>"
	         + "<td align='center'><input type='checkbox' name='drug_type'/></td>"
	         + "<td><a href='javascript:void(0)' onclick='deleteRow(this)' style='text-decoration:none;margin-left:18px;width:50px'>删除</a></td></tr>";
	         
			$("#tableid").append(html); 
	
			resetNum(0);
	
			$("#western_drug_name_" + count).autocomplete(
					"${path}/auto?method=getDrugList&campus=${currentUserCampus}",
					{
						max : 12, //列表里的条目数 
						minChars : 1, //自动完成激活之前填入的最小字符 
						width : 215, //提示的宽度，溢出隐藏 
						scrollHeight : 300, //提示的高度，溢出显示滚动条 
						matchContains : false, //包含匹配，就是data参数里的数据，是否只要包含文本框里的数据就显示 
						autoFill : false, //自动填充 
						parse: function(data){    
	                        var rows = [];    
	                        var d = data;    
	                        for(var i=0; i<d.length; i++){    
	                         rows[rows.length] = {    
	                           data:d[i], //每条数据对象   
	                           value:d[i].name+d[i].pin_yin, //与输入的值比较的数据  
	                           result:d[i].name  //选中的实际数据  
	                         };    
	                        } 
	                        return rows;    
	                    },
						formatItem : function(row, i, max) {
							return "<div style='float:left'>" + row.name + "</div>"
									+"<div style='float:right' class='kucun';>库存："+ row.drugstore_num +"</div>";
						},
						formatMatch : function(row, i, max) {
							return row.name;
						},
						formatResult : function(row) {
							return row.name;
						}
					}).result(function(event, row, formatted) {
					
						$(this).parent().parent().find("input[name='spec']").val(row.spec);
						$(this).parent().parent().find("input[name='drugId']").val(row.id);
						$(this).parent().parent().find("input[name='drugstore_num']").val(row.drugstore_num);
						$(this).parent().parent().find("input[name='supply_price']").val(row.supply_price);
						$(this).parent().parent().find("input[name='supply_price']").hide();
					});
			count++;
		}
		
		//--------------------------------------------------
		//中药的处理方式
		
		function doChineseClick()
		{
			var html = "<tr height='25px'><td width='30px' align='center' name='td_num'></td><td width='170px' align='center'><input type='hidden' name='drugId'/><input type='text'  name='chinese_drug_name' value='输入药品名/药品拼音' class='normalKw'  onfocus='removeWaterMark(this);' onblur='addWaterMark(this);' id='chinese_drug_name_"+count+"'></td>"
	         + "<td align='center'><input type='text' name='spec' readonly style='border:0;width:80px; text-align:center'></td>"
	         + "<td align='center'><input type='text' name='drugstore_num' readonly style='border:0;width:50px' text-align:center'></td>"
	         + "<td align='center'><input type='text' name='quantity' style='border:0;width:50px' onkeyup='countAmount()' text-align:center'></td>"
	         + "<td><input type='text' name='supply_price' style='border:0;width:50px' readonly text-align:center'></td>"
	         + "<td align='center' name='td_method'><ui:select pvalue='method' name=''/></td>"
	         + "<td><a href='javascript:void(0)' onclick='deleteRow(this)' style='text-decoration:none;margin-left:18px;width:50px'>删除</a></td></tr>";
			$("#chineseTable tr").eq(-2).append(html); 
	
			resetNum(1);
				
			$("#chinese_drug_name_" + count).autocomplete(
					"${path}/auto?method=getDrugList&campus=${currentUserCampus}",
					{
						max : 12, //列表里的条目数 
						minChars : 1, //自动完成激活之前填入的最小字符 
						width : 215, //提示的宽度，溢出隐藏 
						scrollHeight : 300, //提示的高度，溢出显示滚动条 
						matchContains : false, //包含匹配，就是data参数里的数据，是否只要包含文本框里的数据就显示 
						autoFill : false, //自动填充 
						parse: function(data){    
	                        var rows = [];    
	                        var d = data;    
	                        for(var i=0; i<d.length; i++){    
	                         rows[rows.length] = {    
	                           data:d[i], //每条数据对象   
	                           value:d[i].name+d[i].pin_yin, //与输入的值比较的数据  
	                           result:d[i].name  //选中的实际数据  
	                         };    
	                        } 
	                        return rows;    
	                    },
						formatItem : function(row, i, max) {
							return "<div style='float:left'>" + row.name + "</div>"
									+"<div style='float:right' class='kucun';>库存："+ row.drugstore_num +"</div>";
						},
						formatMatch : function(row, i, max) {
							return row.name;
						},
						formatResult : function(row) {
							return row.name;
						}
					}).result(function(event, row, formatted) {
					
						$(this).parent().parent().find("input[name='spec']").val(row.spec);
						$(this).parent().parent().find("input[name='drugId']").val(row.id);
						$(this).parent().parent().find("input[name='drugstore_num']").val(row.drugstore_num);
						$(this).parent().parent().find("input[name='supply_price']").val(row.supply_price);
					});
				count++;
		}
		
		function doSave()
   		{
			var description = "";
			$("#table_description input").each(function(){
				if($.trim($(this).val()) != "")
				{
					description += $(this).val() + "||";
				}
			});
			
			if(currentTab == "western"){
				if(doCheckWestern(description))
				{
					var array = [];
					$("#tableid").find("tr").each(function(i){
						if(i != 0)
						{
							var m = {};
							m.drugId = $(this).find("input[name='drugId']").val();
							m.quantity = $(this).find("input[name='quantity']").val();
							m.method = $(this).find("td[name='td_method'] select").val();
							m.times = $(this).find("td[name='td_times'] select").val();
							m.consumption =$(this).find("td[name='consumption'] input").val()+ $(this).find("td[name='consumption'] select").val();
							m.drug_type = $(this).find("td input[name='drug_type']:checked").length == 0 ? '0' : '2';
							array.push(m);
						}
					});
					
					saveDiagnose(array,description,"western");
					
				}
			}else{
				if(doCheckChinese(description))
				{
					var array = [];
					$("#chineseTable").find("tr").each(function(i){
						if(i != 0)
						{
							var m = {};
							m.drugId = $(this).find("input[name='drugId']").val();
							m.quantity = $(this).find("input[name='quantity']").val();
							m.method = $(this).find("td[name='td_method'] select").val();
							//1代表中药
							m.drug_type = 1;
							array.push(m);
						}
					});
					//最后一行是总共贴数，所以要移除
					array.pop();
					saveDiagnose(array,description,"chinese");
				}
			}
			
   		}
		
		function saveDiagnose(array,description,currentTab)
		{
			var map = {};
			if(currentTab == "chinese")
			{
				map.post_number = $("#post_number").val();
			}
			map.description = description;
			var symptom = "";
			$("input[name='symptom']:checked").each(function(){
				symptom += $(this).val() + ",";
			});
			
			map.symptom = symptom.substring(0,symptom.length - 1);
			map.recordId = record_id;
			map.diagnoseId = $("#diagnoseId").val();
			ajax.remoteCall("com.system.dao.DoctorDao:saveDiagnose",[array,map],function(reply){
				var result = reply.getResult();
				alert(result.value);
				if(result.type == "success")
				{
					var dlg = Dialog.getInstance("view");
					var parent = dlg.getParam("window");
					parent.is_advice = "false";
					parent.is_diagnose = "true";
					dlg.close();
				}
			});
		}
 		
		function addDescription()
		{
			var len = $("#table_description tr").length + 1;
			var html = "<tr><td width='25px' align='center' name='desc_num'>" + len + "、</td><td><input type='text' style='width:200px;border:0'/></td></tr>";
			$("#table_description").append(html);
		}
		
		function delDescription()
		{
			$("#table_description tr:last").remove();
		}
		
		//校验中药处方
		function doCheckChinese(description)
		{
			var flag = true;
			
			if($.trim($("#post_number").val())=="" || !check_integer($("#post_number").val()) || $("#post_number").val() <= 0)
			{
				alert("帖数不能为空并且要是大于0的数字");
				return false;
			}
			
			if(description == "")
			{
				alert("诊断描述不可为空");
				return false;
			}
			
			if($("#chineseTable tr").length == 1)
			{
				alert("药品不能为空");
				return false;
			}
			
			$("input[name='chinese_drug_name']").each(function(){
				
				if($.trim($(this).val()) == "" || $(this).val() == '输入药品名/药品拼音')
				{
					alert("药品名称不能为空");
					$(this).focus();
					flag = false;
					return;
				}
			});
			
			if(!flag)
			{
				return false;
			}
			
			$("#chineseTable input[name='quantity']").each(function(){
				
				if($.trim($(this).val())=="" || !check_integer($.trim($(this).val())) || $(this).val() <= 0)
				{
					alert("药品数量不能为空并且要是大于0的数字");
					$(this).focus();
					flag = false;
					return;
				}
			}); 
			
			$("#chineseTable input[name='quantity']").each(function(){
				if(parseInt($(this).val()) > parseInt($(this).parent().parent().find("input[name='drugstore_num']").val()))
				{
					alert("药品数量不能大于库存数量");
					$(this).focus();
					flag = false;
					return;
				}
			}); 
			
			if(!flag)
			{
				return false;
			}
			
			
			$("#chineseTable td[name='td_method'] select").each(function(){
				
				if($(this).val() == "")
				{
					alert("请您填写使用方法");
					$(this).focus();
					flag = false;
					return;
				}
			});
			
			if(!flag)
			{
				return false;
			}
			
			if(parseFloat($("#totalAmount").val()) > parseFloat($("#max_consume").val()))
			{
				alert("不能超过单次最大就诊金额");
				return false;
			}
			return flag;
		}
		
		//校验西药处方
		function doCheckWestern(description)
		{
			var flag = true;
			
			if(description == "")
			{
				alert("诊断描述不可为空");
				return false;
			}
			
			if($("#tableid tr").length == 1)
			{
				alert("药品不能为空");
				return false;
			}
			
			$("input[name='western_drug_name']").each(function(){
				
				if($.trim($(this).val()) == "" || $(this).val() == '输入药品名/药品拼音')
				{
					alert("药品名称不能为空");
					$(this).focus();
					flag = false;
					return;
				}
			});
			
			if(!flag)
			{
				return false;
			}
			
			$("#tableid input[name='quantity']").each(function(){
				
				if($.trim($(this).val())=="" || !check_integer($.trim($(this).val())) || $(this).val() <= 0)
				{
					alert("药品数量不能为空并且要是大于0的数字");
					$(this).focus();
					flag = false;
					return;
				}
			}); 
			
			$("#tableid input[name='quantity']").each(function(){
				if(parseInt($(this).val()) > parseInt($(this).parent().parent().find("input[name='drugstore_num']").val()))
				{
					alert("药品数量不能大于库存数量");
					$(this).focus();
					flag = false;
					return;
				}
			}); 
			
			if(!flag)
			{
				return false;
			}
			
			
			$("#tableid td[name='td_method'] select").each(function(){
				
				if($(this).val() == "")
				{
					alert("请您填写使用方法");
					$(this).focus();
					flag = false;
					return;
				}
			});
			
			if(!flag)
			{
				return false;
			}
			
			$("#tableid td[name='consumption'] input").each(function(){
				
				if($(this).val() == "")
				{
					alert("请您填写用量");
					$(this).focus();
					flag = false;
					return;
				}
			});
			
			if(!flag)
			{
				return false;
			}
			
			$("td[name='td_times'] select").each(function(){
				
				if($(this).val() == "")
				{
					alert("请您填写使用次数");
					$(this).focus();
					flag = false;
					return;
				}
			});
			
			if(parseFloat($("#totalAmount").val()) > parseFloat($("#max_consume").val()))
			{
				alert("不能超过单次最大就诊金额");
				return false;
			}
			return flag;
		}
		
		//解决js浮点数加法不精准的bug
		function add(arg1,arg2){ 
			var r1,r2,m; 
			try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0} 
			try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0} 
			m=Math.pow(10,Math.max(r1,r2)) 
			return (arg1*m+arg2*m)/m 
		} 

		//计算金额
		function countAmount()
		{
			var total = 0;
			$("#tableid").find("tr").each(function(i){
				if(i != 0)
				{
					var quantity = $(this).find("input[name='quantity']").val();
					var supply_price = $(this).find("input[name='supply_price']").val();
					total = add(total,quantity * supply_price);
				}
			});
			if(total < $("#max_consume").val())
			{
				$("#totalAmount").css("color","green");
			}else{
				$("#totalAmount").css("color","red");
			}
			$("#totalAmount").val(total);
		}
  </script>
  
  <body style="overflow-x: hidden;overflow-y:hidden;">
  <form id="winForm" name="winForm">
  		<input id="diagnoseId" name="diagnoseId" type="hidden" value="${diagnoseMap['id']}">
    	<table cellSpacing="0" cellPadding="0" style="width:100%;height:100%" border="0">
			<tr>
				<td>
					<table cellSpacing="0" cellPadding="0" width="100%" border="0" bgcolor="#F0FFFF">
						<tr>
							<td colspan="2">
								<table cellSpacing="0" cellPadding="0" width="100%" border="0" bgcolor="#F0FFFF" style="font-size: 12px">
									<tr style="padding:5;hight:30px">
										<td width="90px">姓名：${personMap['name']}</td>
										<td width="90px">
											类型：
											<c:choose>
												<c:when test="${personMap['type'] == 0}">学生</c:when>
												<c:when test="${personMap['type'] == 1}">教职工</c:when>
												<c:when test="${personMap['type'] == 2}">退休</c:when>
												<c:when test="${personMap['type'] == 3}">离休</c:when>
												<c:when test="${personMap['type'] == 4}">其他</c:when>
											</c:choose>
										</td>
										<td width="160px">电话：${personMap['telephone']}</td>
										<td width="180px">既往病史：${personMap['anamnesis']}</td>
										<td width="160px">今年就诊次数：${personMap['times']}</td>
										<td width="170px">单笔最高金额(元)：<input id="max_consume" readonly value="${personMap['max_consume']}" style="border: 0;width: 60px;background-color: #F0FFFF" /></td>
									<tr style="padding:5;hight:30px">
										<td width="90px">性别：${personMap['sex']}</td>
						   	 			<td width="90px">地址：${personMap['address']}</td>
						   	 			<td width="160px">上次就诊时间：${personMap['last_time']}</td>
						   	 			<td width="180px">班级/部门：${personMap['class']}</td>
										<td width="160px">今年就诊总额：${personMap['amount']}</td>
										<td width="170px">本次就诊金额(元)：<input id="totalAmount" readonly style="border: 0;width: 60px;background-color: #F0FFFF" /></td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td width="870px">
								<div style="background-color:#F0FFFF;">
			          	    		<div id="div_tabs" class="easyui-tabs" style="height:320px;">
										<div title="西药处方" style="padding:10px;background-color:#F7F7F7;">											
											<div id="westernDiv" style="float:center;display:inline;font-family: serif;font-size: 10px; <c:if test="${diagnoseMap['post_number'] != null}">display:none</c:if>">
												<table class="showtable" id="tableid" align="left" border="1px" width="820px">
													   <tr>
													   	   <th width="40px">序号</th>
														   <th width="200px">药品名称</th>
														   <th width="80px">规格</th>
														   <th width="50px">库存</th>
														   <th width="50px">数量</th>
														   <th width="40px" style="display:none">单价</th>
														   <th width="70px">使用方法</th>
														   <th width="55px">用量</th>
														   <th width="70px">使用次数</th>
														   <th width="90px">用于注射</th>
														   <th width="70px">操作</th>
													   </tr>
													   <c:if test="${diagnoseMap['post_number'] == null}">
														   <c:forEach items="${list}" var="obj" varStatus="status">
															   <tr>
															   		<td name="td_num" width='30px' align='center'>${status.count }</td>
															   		<td width='140px' align='center'>
															   			<input type='hidden' name='drugId' value="${obj.drug_id }"/>
															   			<input type='text'  name='western_drug_name' value='${obj.name}' class='normalKw2'  onfocus='removeWaterMark(this);'>
															   		</td>
				         											<td align='center'>
				         												<input type='text' name='spec' value="${obj.spec}" readonly style='border:0;width:80px; text-align:center'>
				         											</td>
				         											<td align='center'>
				         												<input type='text' name='drugstore_num' value="${obj.drugstore_num}" style='border:0;width:50px;text-align:center' readonly onkeyup="countAmount()">
				         											</td>
				         											<td align='center'>
				         												<input type='text' name='quantity' value="${obj.quantity}" style='border:0;width:50px;text-align:center' onkeyup="countAmount()">
				         											</td>
				         											<td style="display:none"><input type='text' name='supply_price' value="${obj.supply_price}" readonly style='border:0;width:60px; text-align:center'></td>
				        											<td align='center' name='td_method'>
				        												<ui:select pvalue='method' name='' value="${obj.use_method}"/>
				        											</td>
				        											<td align='center' name='consumption'>
				         												<%-- <input type='text' name='consumption' value="${obj.consumption}" readonly style='border:0;width:60px; text-align:center'> --%>
				         												<div>
				         													<div style="display:inline;"><input id='general' value="${fn:substring(obj.consumption,0,1)}"/></div>
				         												<div style="display:inline;"><select style="width:40px">
				         													<option selected="selected">${fn:substring(obj.consumption,1,2)}</option>
				         													<option>粒</option>
				         													<option>片</option>
				         													<option>瓶</option>
				         													<option>ml</option>
				         													<option>mg</option>
				         													<option>g</option>
				         													<option>枚</option>
				         													<option>丸</option>
				         													<option>#</option>
				         												</select>
				         												</div>
				         												</div>
				         											</td>
				        											<td align='center' name='td_times'>
				        												<ui:select pvalue='times' name='' value="${obj.times}"/>
				        											</td>
				        											<td align='center'>
				        												<input type='checkbox' name='drug_type' <c:if test="${obj.type == '2'}">checked</c:if> />
				        											</td>
				         											<td>
				         												<a href='javascript:void(0)' onclick='deleteRow(this)' style='text-decoration:none;margin-left:18px;width:50px'>删除</a>
				         											</td>
				         										</tr>
														  </c:forEach>
													  </c:if>
												</table>
												<img id="addbutton" title="点击增加" src="${path }/images/add.png" style="width:24px;height:24px;cursor:pointer" onclick="doWesternClick()"></img>
											</div>
											
										</div>
										
										<div title="中药处方" style="padding:10px;background-color:#F7F7F7;">
											<div id="chineseDiv" style="float:center;display:inline;font-family: serif;font-size: 10px; <c:if test="${diagnoseMap['post_number'] == null}">display:none</c:if>">
												<table class="showtable" id="chineseTable" align="left" border="1px" width="820px">
													   <tr>
													   	   <th width="40px">序号</th>
														   <th width="150px">药品名称</th>
														   <th width="80px">规格</th>
														   <th width="50px">库存</th>
														   <th width="50px">数量</th>
														   <th width="40px">单价</th>
														   <th width="70px">使用方法</th>
														   <th width="70px">操作</th>
													   </tr>
													   <c:if test="${diagnoseMap['post_number'] != null}">
														   <c:forEach items="${list}" var="obj" varStatus="status">
															   <tr>
															   		<td name="td_num" width='30px' align='center'>${status.count }</td>
															   		<td width='150px' align='center'>
															   			<input type='hidden' name='drugId' value="${obj.drug_id }"/>
															   			<input type='text'  name='chinese_drug_name' value='${obj.name}' class='normalKw2'  onfocus='removeWaterMark(this);'>
															   		</td>
				         											<td align='center'>
				         												<input type='text' name='spec' value="${obj.spec}" readonly style='border:0;width:80px; text-align:center'>
				         											</td>
				         											<td align='center'>
				         												<input type='text' name='drugstore_num' value="${obj.drugstore_num}" style='border:0;width:50px' readonly onkeyup="countAmount()">
				         											</td>
				         											<td align='center'>
				         												<input type='text' name='quantity' value="${obj.quantity}" style='border:0;width:50px' onkeyup="countAmount()">
				         											</td>
				         											<td align='center'>
				         												<input type='text' name='supply_price' value="${obj.supply_price}" readonly style='border:0;width:60px; text-align:center'>
				         											</td>
				        											<td align='center' name='td_method'>
				        												<ui:select pvalue='method' name='' value="${obj.use_method}"/>
				        											</td>
				         											<td>
				         												<a href='javascript:void(0)' onclick='deleteRow(this)' style='text-decoration:none;margin-left:18px;width:50px'>删除</a>
				         											</td>
				         										</tr>
														  </c:forEach> 
													  </c:if>
													  <tr height="30px">
													  	<td colspan="8" align="right" style="font-size: 13px;">总共:<input id="post_number" value="${diagnoseMap['post_number']}" type="text" style="border:0;;width:80px;BORDER-RIGHT: medium none;BORDER-TOP: medium none;BORDER-LEFT: medium none;BORDER-BOTTOM:black 1px solid;text-align: center;"/>帖<span style="margin-left: 30px"></span></td>
													  </tr>
												</table>
												<img id="addChinesebutton" title="点击增加" src="${path }/images/add.png" style="width:24px;height:24px;cursor:pointer" onclick="doChineseClick()"></img>
											</div>
											
										</div>
						  			</div>
								</div>
							</td>
							
							<td>
								<div class="right_main" style="float:right;display:inline;">
									<div class="remind_main ">
										<div class="tip_div" style="height:100%">
											<div class="tip_item tip3" style="width:100%;font-size:16;margin-left:10;"><span id="span_description">诊断描述</span>
												<img style="margin-left: 60px;cursor: pointer;" width="20px" height="20px" alt="点击增加一行" src="${path}/images/addButton.png" onclick="addDescription()" />
												<img style="margin-left: 10px;cursor: pointer;" alt="点击删除最后一行" width="20px" height="20px" src="${path}/images/erase.png" onclick="delDescription()">
											</div>
										</div>
										<div id="remindDiv" style="background-color: white;">
											<table id="table_description" border="0" cellpadding="0" cellspacing="0">
												<c:forEach var="obj" items="${fn:split(diagnoseMap['description'],'||')}" varStatus="status">
													<c:if test="${obj != '' }">
														<tr>
															<td width='25px' align='center' name='desc_num'>${status.count}、</td>
															<td>
																<input type='text' style='width:200px;border:0' value="${obj}"/>
															</td>
														</tr>
													</c:if>
												</c:forEach>
											</table>
										</div>
									</div>
								</div>	
							</td>
						</tr>
						<tr>
							<td colspan="3">
								<div class="right_main" style="width:100%;">
									<div class="remind_main ">
										<div class="tip_div" style="height:100%">
										<div class="tip_item tip3" style="width:100%;font-size:16;margin-left:10;">症状 </div>
										</div>
									<div id="remindDiv" >
										<div style="width:100%;height:140px;background-color:#F0FFFF">
											<ui:checkbox id="symptom" nbspnum="5" pvalue="Symptom" name="symptom" value="${diagnoseMap['symptom'] }"/></div>
										</div>
									</div>
								</div>		
							</td>
						</tr>
					</table>
				</td>
   		</table>
   		</form>
  </body>
   
</html>
